package com.ken.wms.common.service.Impl;

import com.ken.wms.common.service.Interface.SystemRegisterService;
import com.ken.wms.dao.UserRegisterMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @version 1.0
 * @Author 程艾影
 * @Date 2025/4/1 20:55
 * @功能:
 */
@Service
public class SystemRegisterServiceImpl implements SystemRegisterService {

    @Autowired
    private UserRegisterMapper userRegisterMapper;


    //执行id和账号名称进行查询判断是否重复
    @Override
    public Boolean register(String id, String userName) {
        //查找到返回的不是0就返回false，等于0就返回true
        int result=userRegisterMapper.register(id,userName);
        if(result>0){
            return false;
        }else {
            return true;
        }
    }

    //调用方法去数据库添加新注册的用户信息---->默认权限是2普通管理员
    @Override
    public void addRegister(String id, String userName, String password, int i) {
        userRegisterMapper.addRegister(id,userName,password,i);
    }

    @Override//获得新用的ID，默认系统分配
    public int get_register_id() {
        return userRegisterMapper.get_register_id();
    }

    //向中间表当中添加用户权限
    @Override
    public void addRegisterRole(String id, int i) {
        userRegisterMapper.addRegisterRole(id,i);
    }

    //向vms_repo_admin当中添加注册的信息
    @Override
    public void addRegisterRoleAndRepo(String id, String userName, String sex, String location, String phone, String date) {
        userRegisterMapper.addRegisterIm(id,userName,sex,location,phone,date);
    }
}
